package com.falcon.controller.exam;

import com.falcon.mvc.domain.BasePager;
import com.falcon.mvc.domain.BaseResponse;
import com.falcon.mvc.base.IBaseController;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;

import com.falcon.domain.dos.ExamAnswerSheetDO;
import com.falcon.domain.req.ExamAnswerSheetQuery;
import com.falcon.domain.req.ExamAnswerSheetRequest;
import com.falcon.service.IExamAnswerSheetService;

@Slf4j
@RestController
@RequestMapping("/exam/examAnswerSheet")
@Tag(name = "ExamAnswerSheetController", description = "答卷-接口")
public class ExamAnswerSheetController  implements IBaseController {

    @Autowired
    private IExamAnswerSheetService examAnswerSheetService;

    @Operation(summary = "新增")
    @PostMapping("/save")
    public BaseResponse<Long> save(@Valid @RequestBody ExamAnswerSheetRequest request) {

        Long id =  this.examAnswerSheetService.save(request);

        return BaseResponse.success(id);
    }

    @Operation(summary = "修改")
    @PutMapping("/update/{id}")
    public BaseResponse<Boolean> update(@PathVariable Long id, @Valid @RequestBody ExamAnswerSheetRequest request) {

        Boolean success =  this.examAnswerSheetService.update(id, request);

        return BaseResponse.success(success);
    }

    @Operation(summary = "删除")
    @DeleteMapping("/delete/{id}")
    public BaseResponse<Boolean> deleteById(@PathVariable Long id) {

        Boolean success =  this.examAnswerSheetService.deleteById(id);

        return BaseResponse.success(success);
    }

    @Operation(summary = "批量删除")
    @PostMapping("/batchDelete")
    public BaseResponse<Integer> batchDelete(@RequestBody List<Long> ids) {

        Integer num =  this.examAnswerSheetService.batchDelete(ids);

        return BaseResponse.success(num);
    }

    @Operation(summary = "查询基本信息")
    @GetMapping("/{id}")
    public BaseResponse<ExamAnswerSheetDO> detail(@PathVariable Long id) {

        ExamAnswerSheetDO examAnswerSheetDo =  this.examAnswerSheetService.queryById(id);

        return BaseResponse.success(examAnswerSheetDo);
    }


    @Operation(summary = "列表查询")
    @PostMapping("/list")
    public BaseResponse<List<ExamAnswerSheetDO>> list(@RequestBody ExamAnswerSheetQuery request) {

        List<ExamAnswerSheetDO> list =  this.examAnswerSheetService.queryList(request);

        return BaseResponse.success(list);
    }

    @Operation(summary = "分页查询")
    @PostMapping("/pager")
    public BaseResponse<BasePager<ExamAnswerSheetDO>> pager(@RequestBody ExamAnswerSheetQuery request) {

        BasePager<ExamAnswerSheetDO> pager =  this.examAnswerSheetService.queryPager(request);

        return BaseResponse.success(pager);
    }


}

